package com.zh.note.leetcode.tree;

import com.zh.note.leetcode.model.TreeNode;

/**
 * 226. 翻转二叉树
 */
public class LC_226_invertTree {

    /**
     * 先序遍历
     * @param root
     * @return
     */
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return root;
        }
        //交换当前节点的左右子节点   中
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;

        invertTree(root.left);//左
        invertTree(root.right);//右
        return root;

    }

}
